package com.myzl.web.controller.coal;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.myzl.common.annotation.Log;
import com.myzl.common.core.controller.BaseController;
import com.myzl.common.core.domain.AjaxResult;
import com.myzl.common.enums.BusinessType;
import com.myzl.coal.domain.DeviceConfig;
import com.myzl.coal.service.IDeviceConfigService;
import com.myzl.common.utils.poi.ExcelUtil;
import com.myzl.common.core.page.TableDataInfo;

/**
 * 设备配置记录Controller
 *
 * @author myzl
 * @date 2022-09-01
 */
@RestController
@RequestMapping("/coal/deviceConfig")
public class DeviceConfigController extends BaseController
{
    @Autowired
    private IDeviceConfigService deviceConfigService;

    /**
     * 查询设备配置记录列表
     */
    @PreAuthorize("@ss.hasPermi('coal:deviceConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(DeviceConfig deviceConfig)
    {
        startPage();
        List<DeviceConfig> list = deviceConfigService.selectDeviceConfigList(deviceConfig);
        return getDataTable(list);
    }

    /**
     * 导出设备配置记录列表
     */
    @PreAuthorize("@ss.hasPermi('coal:deviceConfig:export')")
    @Log(title = "设备配置记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeviceConfig deviceConfig)
    {
        List<DeviceConfig> list = deviceConfigService.selectDeviceConfigList(deviceConfig);
        ExcelUtil<DeviceConfig> util = new ExcelUtil<DeviceConfig>(DeviceConfig.class);
        util.exportExcel(response, list, "设备配置记录数据");
    }

    /**
     * 获取设备配置记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('coal:deviceConfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(deviceConfigService.selectDeviceConfigById(id));
    }

    /**
     * 新增设备配置记录
     */
    @PreAuthorize("@ss.hasPermi('coal:deviceConfig:add')")
    @Log(title = "设备配置记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DeviceConfig deviceConfig)
    {
        return toAjax(deviceConfigService.insertDeviceConfig(deviceConfig));
    }

    /**
     * 修改设备配置记录
     */
    @PreAuthorize("@ss.hasPermi('coal:deviceConfig:edit')")
    @Log(title = "设备配置记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DeviceConfig deviceConfig)
    {
        return toAjax(deviceConfigService.updateDeviceConfig(deviceConfig));
    }

    /**
     * 删除设备配置记录
     */
    @PreAuthorize("@ss.hasPermi('coal:deviceConfig:remove')")
    @Log(title = "设备配置记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(deviceConfigService.deleteDeviceConfigByIds(ids));
    }
}
